home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / Q-R / QB Graphics.sea / event shell.bas < prev    next >
BASIC Source File  |  1991-04-21  |  22KB  |  710 lines

  1. '------------------------------------------------------------------------------
  2. ' TITLE:    event shell
  3. ' DATE:     March 6, 1991
  4. ' AUTHOR: R. Gonzalez
  5. '
  6. ' DESCRIPTION:  Sample event-loop application, for use as a shell to develop
  7. ' new applications.  Demonstrates defining menus and windows and polling for
  8. ' events.  Also demonstrates how to verify edit field values (try typing "Richard
  9. ' Nixon" in the data field), show alternative cursors (select the "Preferences"
  10. ' menu item), and track the mouse position.
  11. '
  12. ' To make your own event-loop application, do the following:
  13. ' (1)   Change the menu routines to suit your application.  You may leave the
  14. '        File menu (and handle.file.menu) unchanged if desired.
  15. ' (2)  Define global (DIM SHARED) variables for your data, in place of those
  16. '        I've defined (mine begin with "dd").
  17. ' (3)   Change initialize.data, save.data, load.data, and the window, button,
  18. '        and edit field routines to handle your own data accordingly.
  19. ' (4)   Set the global variable changes% to TRUE% and call menu.after.changes
  20. '        when the user changes one of your own global data variables.  Note that
  21. '        if you have edit fields then you may need to actively check whether
  22. '        the user has typed anything - see my use of check.for.edit.changes.
  23. '
  24. ' COMPILING:    Remove STATIC declarations, uncomment indicated lines
  25. '     Check: Include MBPCs & MBLCs, Include runtime code, Make all arrays static,
  26. '     Use default window & menu, (if available: Generate 68020 & 68881 code).
  27. '
  28. ' (MODIFICATION HISTORY)
  29. ' DATE:     
  30. ' AUTHOR: 
  31. ' DESCRIPTION:  
  32. '------------------------------------------------------------------------------
  33.  
  34. ' these variables may be shared among several subprograms:
  35. DIM SHARED TRUE%,FALSE%,menu.state%,changes%,window.open%,winx%,winy%
  36. DIM SHARED pi,pic%(2400),selected.field%
  37. ' global data variables:
  38. DIM SHARED dd.edit1$,dd.edit2$,dd.circle.on%
  39. '------------------------------------------------------------------------------
  40. ' main procedure
  41. '------------------------------------------------------------------------------
  42. 'MAIN
  43.     
  44.     DIM done%,menu.event%,window.event%,window.number%,mouse.event%
  45.     DIM file.name$
  46.  
  47.     WINDOW CLOSE 1  'close default window
  48.  
  49.     TRUE% = -1
  50.     FALSE% = 0
  51.     pi = 3.14159
  52.     
  53.     initialize.data
  54.     setup.menu
  55.     file.name$ = "Untitled"
  56.     open.main.window file.name$,TRUE%
  57.     window.open% = TRUE%
  58.     done% = FALSE%
  59.  
  60.     ' main event loop
  61.     WHILE NOT done%
  62.     
  63.         menu.event% = MENU(0)
  64.         IF menu.event% <> 0 THEN
  65.             handle.menu menu.event%,file.name$,done%
  66.         END IF
  67.  
  68.         window.event% = DIALOG(0)
  69.         'In case you decide to use multiple windows:
  70.         window.number% = WINDOW(0)
  71.         IF window.event% <> 0 THEN
  72.             handle.window window.event%,window.number%,file.name$
  73.         END IF
  74.  
  75.         mouse.event% = MOUSE(0)
  76.         IF window.open% AND mouse.event% <> 0 THEN
  77.             handle.mouse mouse.event%,window.number%
  78.         END IF
  79.  
  80.         'No QuickBASIC event is generated when you type in an edit field,
  81.         'so check for changes periodically:
  82.         IF window.open% THEN
  83.             check.for.edit.changes
  84.         END IF
  85.         
  86.     WEND
  87.         
  88. END
  89.  
  90. '------------------------------------------------------------------------------
  91. ' initialize global data
  92. '------------------------------------------------------------------------------
  93. SUB initialize.data STATIC
  94.  
  95.     dd.edit1$ = ""
  96.     dd.edit2$ = ""
  97.     dd.circle.on% = FALSE%
  98.     
  99.     changes% = FALSE%
  100.     selected.field% = 1
  101.     
  102. END SUB
  103.  
  104. '------------------------------------------------------------------------------
  105. ' set up opening menu
  106. '------------------------------------------------------------------------------
  107. SUB setup.menu STATIC
  108.  
  109.     menu.state% = 0
  110.     
  111.     MENU 1,0,1,"File"
  112.     MENU 1,1,1,"New"
  113.     MENU 1,2,1,"Open...":cmdkey 1,2,"O"
  114.     MENU 1,3,1,"Close"
  115.     MENU 1,4,0,"Save":cmdkey 1,4,"S"
  116.     MENU 1,5,1,"Save As..."
  117.     MENU 1,6,1,"Print..."
  118.     MENU 1,7,1,"Quit":cmdkey 1,7,"Q"
  119.  
  120.     ' use default edit menu
  121.  
  122.     MENU 3,0,1,"Data"
  123.     MENU 3,1,1,"Preferences..."
  124.  
  125. END SUB
  126.  
  127. '------------------------------------------------------------------------------
  128. ' menu when no window open
  129. '------------------------------------------------------------------------------
  130. SUB windowless.menu STATIC
  131.  
  132.     menu.state% = 1
  133.     
  134.     MENU 1,0,1,"File"
  135.     MENU 1,1,1,"New"
  136.     MENU 1,2,1,"Open...":cmdkey 1,2,"O"
  137.     MENU 1,3,0,"Close"
  138.     MENU 1,4,0,"Save":cmdkey 1,4,"S"
  139.     MENU 1,5,0,"Save As..."
  140.     MENU 1,6,0,"Print..."
  141.     MENU 1,7,1,"Quit":cmdkey 1,7,"Q"
  142.  
  143.     ' use default edit menu
  144.  
  145.     MENU 3,0,0,"Data"
  146.     MENU 3,1,0,"Preferences..."
  147.  
  148. END SUB
  149.  
  150. '------------------------------------------------------------------------------
  151. ' menu when window contents have changed
  152. '------------------------------------------------------------------------------
  153. SUB menu.after.changes STATIC
  154.  
  155.     menu.state% = 2
  156.     
  157.     MENU 1,0,1,"File"
  158.     MENU 1,1,1,"New"
  159.     MENU 1,2,1,"Open...":cmdkey 1,2,"O"
  160.     MENU 1,3,1,"Close"
  161.     MENU 1,4,1,"Save":cmdkey 1,4,"S"
  162.     MENU 1,5,1,"Save As..."
  163.     MENU 1,6,1,"Print..."
  164.     MENU 1,7,1,"Quit":cmdkey 1,7,"Q"
  165.  
  166.     ' use default edit menu
  167.  
  168.     MENU 3,0,1,"Data"
  169.     MENU 3,1,1,"Preferences..."
  170.  
  171. END SUB
  172.  
  173. '------------------------------------------------------------------------------
  174. ' redraw current menu
  175. '------------------------------------------------------------------------------
  176. SUB restore.menu STATIC
  177.  
  178.     SELECT CASE menu.state%
  179.         CASE 0:    setup.menu
  180.  
  181.         CASE 1:    windowless.menu
  182.         
  183.         CASE 2:    menu.after.changes
  184.         
  185.         CASE ELSE:
  186.         
  187.     END SELECT
  188.         
  189. END SUB
  190.     
  191. '------------------------------------------------------------------------------
  192. ' check what menu was chosen
  193. '------------------------------------------------------------------------------
  194. SUB handle.menu (menu.no%,file.name$,done%) STATIC
  195.  
  196.     ' for compiler only:
  197. '    dim menu.item%
  198.  
  199.     menu.item% = MENU(1)
  200.     
  201.     SELECT CASE menu.no%
  202.         CASE 1:    handle.file.menu menu.item%,file.name$,done%
  203.  
  204.         ' let QB handle the default edit menu on its own
  205.         
  206.         CASE 3:    handle.data.menu menu.item%
  207.  
  208.         CASE ELSE:
  209.  
  210.     END SELECT
  211.  
  212. END SUB
  213.  
  214. '------------------------------------------------------------------------------
  215. ' check what file menu item was chosen
  216. '------------------------------------------------------------------------------
  217. SUB handle.file.menu (menu.item%,file.name$,done%) STATIC
  218.  
  219.     ' for compiler only:
  220. '   dim new.name$,short.name$,success%
  221.  
  222.     SELECT CASE menu.item%
  223.         CASE 1:    IF window.open% THEN
  224.                             close.main.window success%
  225.                             window.open% = NOT success%
  226.                         END IF
  227.                         IF NOT window.open% THEN
  228.                             file.name$ = "Untitled"
  229.                             initialize.data
  230.                             open.main.window file.name$,TRUE%
  231.                             window.open% = TRUE%
  232.                             setup.menu
  233.                         ELSE
  234.                             restore.menu
  235.                         END IF
  236.  
  237.         CASE 2:    IF window.open% THEN
  238.                             close.main.window success%
  239.                             window.open% = NOT success%
  240.                         END IF
  241.                         IF NOT window.open% THEN
  242.                             new.name$ = FILES$(1,"TEXT")
  243.                             IF new.name$ <> "" THEN
  244.                                 file.name$ = new.name$
  245.                                 open.main.window file.name$,TRUE%
  246.                                 window.open% = TRUE%
  247.                                 setup.menu
  248.                             ELSE
  249.                                 windowless.menu
  250.                             END IF
  251.                         ELSE
  252.                             restore.menu
  253.                         END IF
  254.  
  255.         CASE 3:    close.main.window success%
  256.                         window.open% = NOT success%
  257.                         IF NOT window.open% THEN
  258.                             file.name$ = ""
  259.                             windowless.menu
  260.                         ELSE
  261.                             restore.menu
  262.                         END IF
  263.  
  264.         CASE 4:    IF file.name$ = "Untitled" THEN
  265.                             new.name$ = FILES$(0,"Save file as:")
  266.                             IF new.name$ <> "" THEN
  267.                                 file.name$ = new.name$
  268.                                 strip.folders file.name$,short.name$
  269.                                 WINDOW 1,short.name$
  270.                             END IF
  271.                             refresh.main.window file.name$
  272.                         END IF
  273.                         IF file.name$ <> "Untitled" THEN
  274.                             save.data file.name$
  275.                             setup.menu
  276.                         ELSE
  277.                             restore.menu
  278.                         END IF
  279.  
  280.         CASE 5:    new.name$ = FILES$(0,"Save file as:")
  281.                         IF new.name$ <> "" THEN
  282.                             file.name$ = new.name$
  283.                             strip.folders file.name$,short.name$
  284.                             WINDOW 1,short.name$
  285.                             save.data file.name$
  286.                             setup.menu
  287.                         ELSE
  288.                             restore.menu
  289.                         END IF
  290.                         refresh.main.window file.name$
  291.  
  292.         CASE 6:    ' print file?
  293.                         restore.menu
  294.  
  295.         CASE 7:    IF window.open% THEN
  296.                             close.main.window success%
  297.                             window.open% = NOT success%
  298.                         END IF
  299.                         IF NOT window.open% THEN
  300.                             done% = TRUE%
  301.                         ELSE
  302.                             restore.menu
  303.                         END IF
  304.  
  305.         CASE ELSE:
  306.  
  307.     END SELECT
  308.  
  309. END SUB
  310.  
  311. '------------------------------------------------------------------------------
  312. ' check what data menu item was chosen
  313. '------------------------------------------------------------------------------
  314. SUB handle.data.menu (menu.item%) STATIC
  315.  
  316.     IF menu.item% = 1 THEN
  317.         ' show "Preferences" dialog?
  318.         restore.menu
  319.     END IF
  320.  
  321.     ' to demonstrate the use of other cursors:
  322.     changecursor 4    ' 1-4 available
  323.     sleep 2!
  324.     INITCURSOR
  325.  
  326. END SUB
  327.  
  328. '------------------------------------------------------------------------------
  329. ' open window for new file
  330. '------------------------------------------------------------------------------
  331. SUB open.main.window (file.name$,do.load%) STATIC
  332.  
  333.     ' for compiler only:
  334. '    dim rect%(4)
  335. '    dim outstring$,title$
  336.  
  337.     strip.folders file.name$,title$
  338.     WINDOW 1,title$,,1
  339.     TEXTFONT 0
  340.     winx% = 5
  341.     winy% = 43
  342.  
  343.     IF file.name$ <> "Untitled" AND do.load% THEN
  344.         load.data file.name$
  345.     END IF
  346.     
  347.     setrect rect%(0),10,10,170,30
  348.     outstring$ = "Honest president:"
  349.     textbox outstring$,rect%(0),0
  350.     EDIT FIELD 1,dd.edit1$,(180,10)-(480,25),1
  351.  
  352.     setrect rect%(0),10,50,170,70
  353.     outstring$ = "Whatever:"
  354.     textbox outstring$,rect%(0),0
  355.     EDIT FIELD 2,dd.edit2$,(180,50)-(480,65),1
  356.  
  357.     IF dd.circle.on% THEN
  358.         CIRCLE (200,200),50
  359.     END IF
  360.     
  361.     fat.button 1,1,"Circle",80,256
  362.     BUTTON 2,1,"Erase",(200,260)-(270,280),1
  363.  
  364.     EDIT FIELD selected.field%    'make this the initially active field
  365.     
  366. END SUB
  367.     
  368. '------------------------------------------------------------------------------
  369. ' try to close window
  370. '------------------------------------------------------------------------------
  371. SUB close.main.window (success%) STATIC
  372.  
  373.     success% = TRUE%
  374.     IF changes% THEN
  375.         alert.changes success%
  376.     END IF
  377.     
  378.     IF success% THEN
  379.         WINDOW CLOSE 1
  380.     END IF
  381.     
  382. END SUB
  383.  
  384. '------------------------------------------------------------------------------
  385. ' load data from file
  386. '------------------------------------------------------------------------------
  387. SUB load.data (file.name$) STATIC
  388.  
  389.     OPEN file.name$ FOR INPUT AS #1
  390.     LINE INPUT #1, dd.edit1$
  391.     LINE INPUT #1, dd.edit2$
  392.     INPUT #1, dd.circle.on%
  393.     CLOSE #1
  394.  
  395.     changes% = FALSE%
  396.     selected.field% = 1
  397.     
  398. END SUB
  399.  
  400. '------------------------------------------------------------------------------
  401. ' save data in file
  402. '------------------------------------------------------------------------------
  403. SUB save.data (file.name$) STATIC
  404.  
  405.     dd.edit1$ = EDIT$(1)    'contents of first edit field in window
  406.     dd.edit2$ = EDIT$(2)
  407.     
  408.     OPEN file.name$ FOR OUTPUT AS #1
  409.     PRINT #1, dd.edit1$
  410.     PRINT #1, dd.edit2$
  411.     PRINT #1, dd.circle.on%
  412.     CLOSE #1
  413.     
  414.     changes% = FALSE%
  415.     
  416. END SUB
  417.  
  418. '------------------------------------------------------------------------------
  419. ' Handle window.  Note we are ignoring window.number% since we only have one window.
  420. '------------------------------------------------------------------------------
  421. SUB handle.window (event.type%,window.number%,file.name$) STATIC
  422.  
  423.     ' for compiler only
  424. '    dim selected.button%,tentative.field%
  425.  
  426.     SELECT CASE event.type%
  427.         CASE 1:    ' button pressed
  428.                         selected.button% = DIALOG(1)
  429.                         handle.main.button selected.button%
  430.  
  431.         CASE 2:    ' new field selected
  432.                         tentative.field% = DIALOG(2)
  433.                         handle.main.edit.field.change tentative.field%
  434.  
  435.         CASE 4:    ' close box pressed
  436.                         'handle.file.menu 3,file.name$,0
  437.                         handle.main.close.box file.name$
  438.         
  439.         CASE 6:    ' RETURN pressed - carry out fat button
  440.                         handle.main.button 1
  441.         
  442.         CASE 7:    ' tab key pressed - go to next edit field
  443.                          IF selected.field% = 1 THEN
  444.                              tentative.field% = 2
  445.                          ELSE
  446.                              tentative.field% = 1
  447.                          END IF
  448.                          EDIT FIELD tentative.field%
  449.                          handle.main.edit.field.change tentative.field%
  450.  
  451.         CASE ELSE:
  452.         
  453.     END SELECT
  454.  
  455. END SUB
  456.  
  457. '------------------------------------------------------------------------------
  458. ' check button in main window
  459. '------------------------------------------------------------------------------
  460. SUB handle.main.button (button.no%) STATIC
  461.  
  462.     SELECT CASE button.no%
  463.         CASE 1:    IF NOT dd.circle.on% THEN
  464.                             dd.circle.on% = TRUE%
  465.                             CIRCLE (200,200),50
  466.                             IF NOT changes% THEN
  467.                                 changes% = TRUE%
  468.                                 menu.after.changes
  469.                             END IF
  470.                         END IF
  471.  
  472.         CASE 2:    IF dd.circle.on% THEN
  473.                             dd.circle.on% = FALSE%
  474.                             forecolor 30
  475.                             CIRCLE (200,200),50
  476.                             forecolor 33
  477.                             IF NOT changes% THEN
  478.                                 changes% = TRUE%
  479.                                 menu.after.changes
  480.                             END IF
  481.                         END IF
  482.                         
  483.         CASE ELSE:
  484.         
  485.     END SELECT
  486.  
  487. END SUB
  488.  
  489. '------------------------------------------------------------------------------
  490. ' this event means that the user has selected another field
  491. '------------------------------------------------------------------------------
  492. SUB handle.main.edit.field.change (active.edit.field.no%) STATIC
  493.  
  494.     ' for compiler only:
  495. '    dim rect%(4),legal%
  496. '    dim outstring$
  497.  
  498.     setrect rect%(0),10,90,270,110
  499.     
  500.     SELECT CASE active.edit.field.no%
  501.         CASE 1:   outstring$ = "Length is: " + STR$(LEN(EDIT$(selected.field%)))
  502.                         textbox outstring$,rect%(0),0
  503.                         selected.field% = active.edit.field.no%  'keep track of current field
  504.         
  505.         CASE 2:    check.selected.field legal%
  506.                         ' you should also probably check this when you "Save" or "Save as..."
  507.                         IF NOT legal% THEN
  508.                             outstring$ = "Illegal value!"    'or put up a dialog window
  509.                             textbox outstring$,rect%(0),0
  510.                             EDIT FIELD selected.field%        ' return to previous field
  511.                         ELSE
  512.                             outstring$ = "OK value."
  513.                             textbox outstring$,rect%(0),0
  514.                             selected.field% = active.edit.field.no%
  515.                         END IF
  516.  
  517.         CASE ELSE:
  518.         
  519.     END SELECT
  520.  
  521. END SUB
  522.  
  523. '------------------------------------------------------------------------------
  524. ' see if field has legal value in it.
  525. '------------------------------------------------------------------------------
  526. SUB check.selected.field (legal%) STATIC
  527.  
  528.     legal% = TRUE%
  529.     
  530.     IF selected.field% = 1 THEN
  531.         IF EDIT$(1) = "Richard Nixon" THEN
  532.             legal% = FALSE%
  533.         END IF
  534.     ELSEIF selected.field% = 2 THEN
  535.         'any restrictions on field 2?
  536.     END IF
  537.     
  538. END SUB
  539.  
  540. '------------------------------------------------------------------------------
  541. ' user has clicked close box of window.  We must reopen it if they change their mind.
  542. ' (Unfortunately QB closes the box before we can intercept it.)
  543. '------------------------------------------------------------------------------
  544. SUB handle.main.close.box (file.name$) STATIC
  545.  
  546.     ' for compiler only
  547. '    dim success%
  548.  
  549.     close.main.window success%
  550.     window.open% = NOT success%
  551.     IF NOT window.open% THEN
  552.         file.name$ = ""
  553.         windowless.menu
  554.     ELSE
  555.         open.main.window file.name$,FALSE%
  556.     END IF
  557.  
  558. END SUB
  559.  
  560. '------------------------------------------------------------------------------
  561. ' Handle mouse click.  Ignore window.number% since there's only one window.
  562. '------------------------------------------------------------------------------
  563. SUB handle.mouse (event.type%,window.number%) STATIC
  564.  
  565.     ' for compiler only
  566. '    dim mouse.x%,mouse.y%,rect%(4)
  567. '    dim outstring$
  568.  
  569.     IF event.type% = 1 THEN    ' mouse was clicked
  570.         mouse.x% = MOUSE(3)    ' x coord when button was first pressed
  571.         mouse.y% = MOUSE(4)    ' y coord when button was first pressed
  572.         setrect rect%(0),10,110,200,130
  573.         outstring$ = "x =" + STR$(mouse.x%) + "    y =" + STR$(mouse.y%)
  574.         textbox outstring$,rect%(0),0
  575.     ELSEIF event.type% = -1 THEN
  576.         ' call routine to handle mouse still down
  577.     END IF
  578.  
  579. END SUB
  580.  
  581. '------------------------------------------------------------------------------
  582. ' check whether edit field was changed, update data variables
  583. '------------------------------------------------------------------------------
  584. SUB check.for.edit.changes STATIC
  585.  
  586.     ' for compiler only:
  587. '    dim entry1$,entry2$
  588.  
  589.     entry1$ = EDIT$(1)
  590.     entry2$ = EDIT$(2)
  591.     
  592.     IF entry1$ <> dd.edit1$ OR entry2$ <> dd.edit2$ THEN
  593.         dd.edit1$ = entry1$
  594.         dd.edit2$ = entry2$
  595.         IF NOT changes% THEN
  596.             changes% = TRUE%
  597.             menu.after.changes
  598.         END IF
  599.     END IF
  600.  
  601. END SUB
  602.  
  603. '------------------------------------------------------------------------------
  604. ' alert user that changes have occurred
  605. '------------------------------------------------------------------------------
  606. SUB alert.changes (continue%) STATIC
  607.  
  608.     ' for compiler only:
  609. '    dim rect%(4)
  610. '    dim outstring$
  611.  
  612.     BEEP
  613.  
  614.     ' you need about 1 integer to store a 13 (?) square pixel area;
  615.     ' make sure pic% is big enough!
  616.     GET (45-winx%,45-winy%)-(240-winx%,210-winy%),pic%
  617.     
  618.     WINDOW 2,,(50,50)-(230,200),-2
  619.     TEXTFONT 0
  620.  
  621.     setrect rect%(0),0,0,180,100
  622.     outstring$ = "Changes have been made.  Continue without saving?"
  623.     textbox outstring$,rect%(0),0
  624.     BUTTON 1,1,"No",(50,120)-(120,135),1
  625.     BUTTON 2,1,"Yes",(50,100)-(120,115),1
  626.  
  627.     clear.dialog.queue
  628.     
  629.     ' local event loop since this is a modal alert
  630.     WHILE DIALOG(0) <> 1
  631.     WEND
  632.  
  633.     IF DIALOG(1) = 1 THEN
  634.         continue% = FALSE%
  635.     ELSE
  636.         continue% = TRUE%
  637.     END IF
  638.  
  639.     WINDOW CLOSE 2
  640.  
  641.     ' refresh the screen
  642.     PUT (45-winx%,45-winy%)-(240-winx%,210-winy%),pic%,PSET
  643.  
  644. END SUB
  645.  
  646. '------------------------------------------------------------------------------
  647. ' reset queue of dialog events
  648. '------------------------------------------------------------------------------
  649. SUB clear.dialog.queue STATIC
  650.  
  651.     WHILE DIALOG(0) <> 0
  652.     WEND
  653.         
  654. END SUB
  655.     
  656. '------------------------------------------------------------------------------
  657. ' draw button with double border
  658. '------------------------------------------------------------------------------
  659. SUB fat.button (button.no%,state%,message$,x%,y%) STATIC
  660.  
  661.     ' for compiler only:
  662. '    dim rect%(4)
  663.  
  664.     setrect rect%(0),x%,y%,x%+76,y%+28
  665.     PENSIZE 3,3
  666.     FRAMEROUNDRECT VARPTR(rect%(0)),16,16
  667.     PENNORMAL
  668.     BUTTON button.no%,state%,message$,(x%+4,y%+4)-(x%+72,y%+24),1
  669.  
  670. END SUB
  671.     
  672. '------------------------------------------------------------------------------
  673. ' remove folder names from file name
  674. '------------------------------------------------------------------------------
  675. SUB strip.folders (file.name$,short.name$) STATIC
  676.  
  677.     short.name$ = file.name$
  678.     
  679.     WHILE INSTR(short.name$,":") > 0
  680.         short.name$ = RIGHT$(short.name$,LEN(short.name$)-INSTR(short.name$,":"))
  681.     WEND
  682.     
  683. END SUB
  684.  
  685. '------------------------------------------------------------------------------
  686. ' wait specified number of seconds
  687. '------------------------------------------------------------------------------
  688. SUB sleep (sleep.time) STATIC
  689.  
  690.     ' for compiler only:
  691. '    dim start.time
  692.  
  693.     start.time = TIMER
  694.     WHILE TIMER < start.time + sleep.time
  695.     WEND
  696.  
  697. END SUB
  698.  
  699. '------------------------------------------------------------------------------
  700. ' Redraw main window for use after file selection dialog.  It would be preferable
  701. ' to use GET/PUT as we do for the alert.changes dialog, but I haven't figured out
  702. ' where the file selection dialog appears, or how big it is.
  703. '------------------------------------------------------------------------------
  704. SUB refresh.main.window (file.name$) STATIC
  705.  
  706.     WINDOW CLOSE 1
  707.     open.main.window file.name$,FALSE%
  708.  
  709. END SUB
  710.